package com.stu.stusystem.model.system.serviceInformation;


import com.stu.stusystem.util.ArithUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.ToString;

@ToString
public class Cpu {
    @ApiModelProperty("核心数")
    private int cpuNum;

    @ApiModelProperty("CPU总的使用率")
    private double total;

    @ApiModelProperty("CPU系统使用率")
    private double sys;

    @ApiModelProperty("CPU用户使用率")
    private double used;

    @ApiModelProperty("CPU当前等待率")
    private double wait;

    @ApiModelProperty("CPU当前空闲率")
    private double free;

    public int getCpuNum() {
        return cpuNum;
    }

    public void setCpuNum(int cpuNum) {
        this.cpuNum = cpuNum;
    }

    public double getTotal() {
        return ArithUtil.round(ArithUtil.mul(total, 100), 2);
    }

    public void setTotal(double total) {
        this.total = total;
    }

    public double getSys() {
        double round = 0.00;
        if (total != 0.00){
            round = ArithUtil.round(ArithUtil.mul(sys / total, 100), 2);
        }
        return round;
    }

    public void setSys(double sys) {
        this.sys = sys;
    }

    public double getUsed() {
        double used = 0.0;
        if (total != 0.00) {
            used = ArithUtil.round(ArithUtil.mul(used / total, 100), 2);
        }
        return used;
    }

    public void setUsed(double used) {
        this.used = used;
    }

    public double getWait() {
        double wait = 0.0;
        if (total != 0.00) {
            wait = ArithUtil.round(ArithUtil.mul(wait / total, 100), 2);
        }
        return wait;
    }

    public void setWait(double wait) {
        this.wait = wait;
    }

    public double getFree() {
        double free = 0.0;
        if (total != 0.00) {
            free = ArithUtil.round(ArithUtil.mul(free / total, 100), 2);
        }
        return free;
    }

    public void setFree(double free) {
        this.free = free;
    }
}
